<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">

<ui:composition template="/templates/tmpl_admin.xhtml">
	<ui:define name="centro">

		<h:form id="form">
			<p:dataTable id="listaNivel" var="nivel" value="#{nivelMBean.niveis}"
				paginator="true" rows="10"
				paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
				rowsPerPageTemplate="5,10,15" emptyMessage="Nenhum nível cadastrado"
				filteredValue="#{nivelMBean.niveisFiltro}" resizableColumns="true"
				selectionMode="single" rowKey="#{nivel.id}"
				selection="#{nivelMBean.nivel}">

				<p:ajax event="rowSelect" update=":form:formulario" oncomplete="nivelDialog.show()" listener="#{nivelMBean.editar}" />

				<f:facet name="header">
					Lista de Níveis
				</f:facet>
				
				<p:column headerText="Código">
					<p:outputLabel value="#{nivel.id}" />
				</p:column>

				<p:column headerText="Descrição" sortBy="#{nivel.descricao}"
					filterBy="#{nivel.descricao}" filterMatchMode="contains">
					<p:outputLabel value="#{nivel.descricao}" />
				</p:column>

				<p:column headerText="Exp. Início">
					<p:outputLabel value="#{nivel.experienciaInicio}" />
				</p:column>

				<p:column headerText="Exp. Fim">
					<p:outputLabel value="#{nivel.experienciaFim}" />
				</p:column>

				<p:column headerText="Máx. Energia">
					<p:outputLabel value="#{nivel.maxEnergia}" />
				</p:column>

				<f:facet name="footer">
					<p:commandButton value="Novo" icon="ui-icon-plus" update=":form:formulario" actionListener="#{nivelMBean.novo}" oncomplete="nivelDialog.show()" />
				</f:facet>
			</p:dataTable>
			
			
			
			<p:dialog header="Nível" widgetVar="nivelDialog" resizable="false"
				showEffect="clip" hideEffect="fold">
				<h:panelGrid id="formulario" columns="2" cellpadding="4">
					<p:outputLabel value="Id" />
					<p:inputText value="#{nivelMBean.nivel.id}" />

					<p:outputLabel value="Descrição" />
					<p:inputText value="#{nivelMBean.nivel.descricao}" />

					<p:outputLabel value="Exp. Início" />
					<p:inputText value="#{nivelMBean.nivel.experienciaInicio}" />

					<p:outputLabel value="Exp. Fim" />
					<p:inputText value="#{nivelMBean.nivel.experienciaFim}" />

					<p:outputLabel value="Máx. Energia" />
					<p:inputText value="#{nivelMBean.nivel.maxEnergia}" />

					<p:commandButton action="#{nivelMBean.salvar}" value="Salvar" update=":form:listaNivel" oncomplete="nivelDialog.hide()" />
					<p:commandButton action="#{nivelMBean.deletar}" value="Deletar" rendered="#{nivelMBean.acao == 'editar'}" update=":form:listaNivel" oncomplete="nivelDialog.hide()" />
					
				</h:panelGrid>
			</p:dialog>

		</h:form>

	</ui:define>
</ui:composition>

</html>
